define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
          // 初始化表格参数配置
          Table.api.init({
            extend: {
                    index_url: 'wadviser/order/index',
                    edit_url: 'wadviser/order/edit',
                    del_url: 'wadviser/order/del',
                    multi_url: 'wadviser/order/multi',
                    table: 'AdviserOrder',
                }
            });

            var table = $('#table');
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                queryParams: function (params) {
                    let filter = JSON.parse(params.filter); // 过滤字段
                    let op = JSON.parse(params.op); // 过滤条件
                    filter.adviser_id = Config.adviser_id;
                    op.adviser_id = '=';
                    params.filter = JSON.stringify(filter);
                    params.op = JSON.stringify(op);
                    return params;
                },
                columns: [
                    [{
                        checkbox: true
                    },
                    {
                        field: '闻道ID',
                        title: __('user_id'),
                        operate: false
                    },
                    {
                        field: 'user.nickname',
                        title: __('昵称'),
                        operate: false
                    },
                    {
                        field: 'wx_code',
                        title: __('微信号'),
                        
                    },
                    {
                        field: 'mobile',
                        title: __('手机号'),
                        
                    },
                    {
                        field: 'adviser.title',
                        title: __('参加实战'),
                    },
                    {
                        field: 'out_trade_no',
                        title: __('订单号'),
                    },
                    {
                        field: 'pay_type',
                        title: __('支付方式'),
                        searchList: {"wechat":__('微信支付'),"alipay":__('支付宝支付')},
                        formatter: Table.api.formatter.label
                    },
                    {
                        field: 'price',
                        title: __('支付金额'),
                        operate: false,
                    },
                    {
                        field:'pay_time',
                        title: __('支付时间'),
                        operate: false,
                    },
                    {field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status}]
                ]
            });

            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($('form[role=form]'));
            }
        }
    };
    return Controller;
});